package com.sora.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("wingstudio第二轮考核文档--基于springsecurity+redis+jwt的登录与注册以及账户过期处理")
                .description("通过捕捉全局异常的方式，统一异常的抛出。使用springsecurity达到前后端分离，通过jwt生成token存储在redis，合理设置redis过期时间，使token能重新发放")
                .version("1.0")
                .contact(new Contact("sora","qq1160478413","wanhhe@qq.com"))
                .build();
    }

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.sora.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
